<template>
  <el-dialog
    v-model="model"
    :close-on-click-modal="false"
    :title="title"
    width="415px"
    @close="model = false"
  >
    <div class="content">
      确定要取消作废当前合同吗？
    </div>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="model = false">取消</el-button>
        <el-button type="primary" @click="okFn">
          确认
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import { ref } from 'vue'
import { contractSearchOperationApi } from '@/api/contract/contractSearch'

export default {
  emits: ['refresh-list'],
  setup(props, { emit }) {
    const model = ref(false)
    const title = ref('取消作废')
    const id = ref()
    
    const show = val => {
      model.value = true
      id.value = val
    }
    const okFn = async() => {
      const res = await contractSearchOperationApi({
        id,
        type: 2
      })
      console.log('取消作废', res)
      if (res.code === '200') {
        ElMessage.success(res.msg)
        emit('refresh-list')
        model.value = false
      }
    }
    return {
      model,
      show,
      title,
      okFn
    }
  }
}

</script>

<style scoped lang="scss">
.content {
  padding: 14px 0 20px 10px;
  font-size: 16px;
  font-weight: 500;
  color: #333;
}
</style>